home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / ip / manage / snmp / mit / bsd / tcp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-17  |  1.0 KB  |  71 lines

  1.  
  2. /*
  3.  *    $Header: tcp.c,v 3.0 91/05/17 16:14:22 jrd Rel $
  4.  *    Author: J. Davin
  5.  *    Copyright 1988, 1989, Massachusetts Institute of Technology
  6.  *    See permission and disclaimer notice in file "notice.h"
  7.  */
  8.  
  9. #include    <notice.h>
  10.  
  11. #include    <sys/types.h>
  12. #include    <sys/socket.h>
  13. #include    <netinet/in.h>
  14.  
  15. #include    <ctypes.h>
  16. #include    <debug.h>
  17. #include    <tcp.h>
  18.  
  19. SmpStatusType    tcpSend (tcp, cp, n)
  20.  
  21. SmpSocketType        tcp;
  22. CBytePtrType        cp;
  23. CIntfType        n;
  24.  
  25. {
  26.     int            result;
  27.  
  28.     if (tcp == (SmpSocketType) 0) {
  29.         return (errBad);
  30.     }
  31.  
  32.     do {    
  33.  
  34.                 result = send ((int) tcp,  (char *) cp,
  35.                         (int) n, (int) 0);
  36.                 n -= result;
  37.                 cp += result;
  38.  
  39.     } while ((result > 0) && (n > 0));
  40.  
  41.     if (result < 0) {
  42.         perror ("tcpSend");
  43.         return (errBad);
  44.     }
  45.     else {
  46.         return (errOk);
  47.     }
  48. }
  49.  
  50. SmpSocketType    tcpNew (so, host, port)
  51.  
  52. int            so;
  53. char            *host;
  54. u_short            port;
  55.  
  56. {
  57.     host = host;
  58.     port = port;
  59.     return ((SmpSocketType) so);
  60. }
  61.  
  62. SmpSocketType    tcpFree (tcp)
  63.  
  64. SmpSocketType    tcp;
  65.  
  66. {
  67.     tcp = tcp;
  68.     return ((SmpSocketType) 0);
  69. }
  70.  
  71.